package com.region.integral.common_user.k.obtain.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.region.integral.common_user.consume.dao.IExchangeK;
import com.region.integral.common_user.k.obtain.IObtainKCurrency;
import com.region.integral.common_user.obtain.dao.IKCurrencyBuyGoods;
import com.region.integral.common_user.obtain.dao.IKCurrencyReward;
import com.region.integral.common_user.obtain.dao.impl.KCurrencyRewardImpl;
import com.region.integral.common_user.obtain.vo.IntegralData;
import com.region.integral.exception.IntegralException;
@Component("common_user_obtainK")
public class KCurrencyImpl implements IObtainKCurrency {
	@Resource(name="iExchangeK")
	private IExchangeK iExchangeK;
	@Resource(name="ikCurrencyBuyGoods")
	private IKCurrencyBuyGoods ikCurrencyBuyGoods;
	@Resource(name="ikCurrencyReward")
	private IKCurrencyReward ikCurrencyReward;
	
	
	@Override
	public boolean byExchangeK(int commonUserid,int KexchangeNum) {
		IntegralData integralData = new IntegralData();
		try {
			iExchangeK.exchangeK(commonUserid, KexchangeNum, integralData);
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.isSuccee();
	}

	@Override
	public boolean byReward(int commonUserid, int kNum) {
		IntegralData integralData = new IntegralData();
		try {
			System.out.println(ikCurrencyReward+".........");
			ikCurrencyReward.reward(commonUserid, kNum, integralData);
			System.out.println("66666666666666666666");
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.isSuccee();
	}

	@Override
	public boolean byBuyGoods(int comomUserid, double price) {
		IntegralData integralData = new IntegralData();
		try {
			ikCurrencyBuyGoods.byGoods(comomUserid, price, integralData);
		} catch (IntegralException e) {
			e.printStackTrace();
		}
		return integralData.isSuccee();
	}

}
